package com.cloudcc.mobile.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;

import com.cloudcc.cloudframe.adapter.CommonAdapter;
import com.cloudcc.cloudframe.adapter.ViewHolder;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.entity.beau.BeauListFilterEntity.SearchFilter;

public class BeauFilterParentAdapter extends CommonAdapter<SearchFilter> {

	private int mSelectPos;
	private OnItemSelectListener mOnItemSelectListener;
	public BeauFilterParentAdapter(Context mContext) {
		super(mContext);
	}

	@Override
	public void convert(ViewHolder holder, SearchFilter t) {
		holder.setText(R.id.tv1, t.label);
		final SearchFilter st =t;
		final int pos =holder.getPostion();
		FrameLayout view = holder.getView(R.id.container);
		view.setBackgroundColor(mSelectPos==holder.getPostion()?Color.parseColor("#F4F9FD"):Color.WHITE);
		view.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mSelectPos =pos;
				notifyDataSetChanged();
				if (mOnItemSelectListener!=null) {
					mOnItemSelectListener.onSelect(st,mSelectPos);
				}
			}
		});
	}

	@Override
	public int getLayoutId() {
		return R.layout.beau_list_filter_parentitem;
	}
	
	public interface OnItemSelectListener{
		void onSelect(SearchFilter t,int pos);
	}

	public int getSelectPos() {
		return mSelectPos;
	}

	public void setSelectPos(int mSelectPos) {
		this.mSelectPos = mSelectPos;
		notifyDataSetChanged();
	}

	public OnItemSelectListener getOnItemSelectListener() {
		return mOnItemSelectListener;
	}

	public void setmOnIteSelectListener(OnItemSelectListener mOnItemSelectListener) {
		this.mOnItemSelectListener = mOnItemSelectListener;
	}

	

}
